//
//  MorePicture.m
//  TheRoadAD
//
//  Created by baixue on 16/8/11.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "MorePicture.h"
#import "MorePictureCell.h"
#import "TopWindow.h"
#import "PictureView.h"//图片
#import "ActivistTableViewController.h"

#define MOREIMG @[@"gengduo1",@"gengduo2",@"gengduo3",@"gengduo4",@"gengduo5"]
@interface MorePicture ()<UITableViewDataSource,UITableViewDelegate>
{
    PictureView *_view;
}
@property (nonatomic, strong) NSMutableArray *imageNameArr;
@end
static NSString * const MORE = @"more";
@implementation MorePicture

- (void)viewDidLoad {
    [super viewDidLoad];
  
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = NO;
    self.tableView.showsVerticalScrollIndicator=NO;

    if (self.index == 0) {
        self.title = @"美图秀秀";
    }else if (self.index == 1){
        self.title = @"趣味视频";
    }else if (self.index == 2){
        self.title = @"聚焦维权";
    }
}



#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return MOREIMG.count;
}



-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return Screen_Width * 178 / 319 + Screen_Width * 94 / 319;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    MorePictureCell *cell  = [tableView dequeueReusableCellWithIdentifier:MORE];
    if (cell == nil) {
         cell = [[[NSBundle mainBundle] loadNibNamed:@"MorePictureCell" owner:nil options:nil] lastObject];
    }
    
    cell.pictureIcon.image = [UIImage imageNamed:MOREIMG[indexPath.row]];
    
    cell.videoLogo.hidden = YES;
    if (self.index == 1) {
        cell.videoLogo.hidden = NO;
        cell.pictureNum.hidden = YES;
    }
    cell.CLICKPICTURE = ^(){
        
        /**
         *  self.index == 0 self.index == 1  美图  视频
         *  self.index == 2  更多维权
         */
        if (self.index == 2) {
            ActivistTableViewController *activist = [[ActivistTableViewController alloc] init];
            [self.navigationController pushViewController:activist animated:YES];
        }else{
        
        UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
        PictureView *view= [[[NSBundle mainBundle] loadNibNamed:@"PictureView" owner:nil options:nil] lastObject];
        _view = view;
        view.imageNameArr = MOREIMG;
        view.frame = [UIScreen mainScreen].bounds;
        [window addSubview:view];
        
        view.NAVBLOCK = ^(NSInteger tag){
            switch (tag) {
                case 101:
                    NSLog(@"点击分享");
                    break;
                case 102:
                    [_view removeFromSuperview];
                    break;
                default:
                    break;
            }
        };
        }

    };
    return cell;
}



@end
